import type { LoginResult, ProfileResult } from '@/types/member'
import { http } from '@/utils/http'

interface LoginParams {
  code: string
  encryptedData: string
  iv: String
}
/**
 * 小程序登录
 * @param data 请求参数
 * @returns
 */
export const postLoginWxMinAPI = (data: LoginParams) => {
  return http<LoginResult>({
    method: 'POST',
    url: '/login/wxMin',
    data,
  })
}

/**
 * 小程序登录-内测版
 * @param phoneNumber 模拟手机号
 * @returns
 */
export const postLoginWxMinSimpleAPI = (phoneNumber: string) => {
  return http<LoginResult>({
    method: 'POST',
    url: '/login/wxMin/simple',
    data: {
      phoneNumber,
    },
  })
}

interface TraditionalLoginParams {
  account: string
  password: string
}

export type TraditionalLoginResult = ProfileResult & {
  cityCode: string
  provinceCode: string
}
/**
 * 传统登录
 * @param data
 * @returns
 */
export const postLoginAPI = (data: TraditionalLoginParams) => {
  return http<LoginResult>({
    method: 'POST',
    url: '/login',
    data,
  })
}
